package com.soilflow.web.controller.dahu;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.soilflow.common.domain.DahuJobhunt;
import com.soilflow.info.service.IDahuJobhuntService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.soilflow.common.annotation.Log;
import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.enums.BusinessType;
import com.soilflow.common.utils.poi.ExcelUtil;
import com.soilflow.common.core.page.TableDataInfo;

/**
 * 求职 Controller
 * 
 * @author party
 * @date 2023-11-02
 */
@RestController
@RequestMapping("/system/jobhunt")
public class DahuJobhuntController extends BaseController {
    @Autowired
    private IDahuJobhuntService dahuJobhuntService;

    /**
     * 查询求职信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:jobhunt:list')")
    @GetMapping("/list")
    public TableDataInfo list(DahuJobhunt dahuJobhunt) {
        startPage();
        List<DahuJobhunt> list = dahuJobhuntService.selectDahuJobhuntList(dahuJobhunt);
        return getDataTable(list);
    }

    /**
     * 获取某个求职 详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:jobhunt:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(dahuJobhuntService.selectDahuJobhuntById(id));
    }

    /**
     * 新增【发布求职信息】
     */
    @PreAuthorize("@ss.hasPermi('system:jobhunt:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DahuJobhunt dahuJobhunt) {
        return toAjax(dahuJobhuntService.insertDahuJobhunt(dahuJobhunt));
    }

    /**
     * 修改【求职信息】
     */
    @PreAuthorize("@ss.hasPermi('system:jobhunt:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DahuJobhunt dahuJobhunt)
    {
        return toAjax(dahuJobhuntService.updateDahuJobhunt(dahuJobhunt));
    }

    /**
     * 删除【求职】
     */
    @PreAuthorize("@ss.hasPermi('system:jobhunt:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dahuJobhuntService.deleteDahuJobhuntByIds(ids));
    }
    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:jobhunt:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DahuJobhunt dahuJobhunt)
    {
        List<DahuJobhunt> list = dahuJobhuntService.selectDahuJobhuntList(dahuJobhunt);
        ExcelUtil<DahuJobhunt> util = new ExcelUtil<DahuJobhunt>(DahuJobhunt.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }
}
